use libc::{c_int, c_void, size_t};
use std::ptr::null_mut;

pub const BINARY_HEAP_NULL: *mut c_void = null_mut();

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub enum BinaryHeapType {
    BINARY_HEAP_TYPE_MIN = 0,
    BINARY_HEAP_TYPE_MAX = 1,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct BinaryHeap {
    pub heap_type: BinaryHeapType,
    pub values: *mut BinaryHeapValue,
    pub num_values: size_t,
    pub alloced_size: size_t,
    pub compare_func: BinaryHeapCompareFunc,
}

pub type BinaryHeapValue = *mut c_void;
pub type BinaryHeapCompareFunc = extern C fn(value1: BinaryHeapValue, value2: BinaryHeapValue) -> c_int;

#[no_mangle]
pub unsafe extern C fn binary_heap_new(heap_type: BinaryHeapType, compare_func: BinaryHeapCompareFunc) -> *mut BinaryHeap {
    // Implementation of binary_heap_new in Rust
}

#[no_mangle]
pub unsafe extern C fn binary_heap_free(heap: *mut BinaryHeap) {
    // Implementation of binary_heap_free in Rust
}

#[no_mangle]
pub unsafe extern C fn binary_heap_insert(heap: *mut BinaryHeap, value: BinaryHeapValue) -> c_int {
    // Implementation of binary_heap_insert in Rust
}

#[no_mangle]
pub unsafe extern C fn binary_heap_pop(heap: *mut BinaryHeap) -> BinaryHeapValue {
    // Implementation of binary_heap_pop in Rust
}

#[no_mangle]
pub unsafe extern C fn binary_heap_num_entries(heap: *mut BinaryHeap) -> size_t {
    // Implementation of binary_heap_num_entries in Rust
}

// ... other functions translated similarly
